/**
 * Range-Based LCM Calculator
 */


const minMul = (num1, num2) => {
  let max = Math.min(num1, num2);
  while (max >= 1) {
    if (num1 % max === 0 && num2 % max === 0) return num1 * num2 / max;
    max--;
  }
  return num1 * num2;
}



const smallestCommons = arr => {
  const floor = Math.min(...arr);
  const ceil = Math.max(...arr);
  let lcm = 1;
  for (let i = floor; i <= ceil; i++) {
    lcm = minMul(lcm, i);
  }
  return lcm;
}


console.log(smallestCommons([1, 5]));